package tx.demo04;

/**
 * notify 和 notifyAll 的使用
 *
 * @author lwj
 * @date 2025-03-13
 * @vesion 1.0.0
 */
public class MainTest {

    /**
     * 静态方法只能访问静态成员
     * @param args
     */
    public static void main(String[] args) {
        MyThread mr1 = new MyThread();
        MyThread mr2 = new MyThread();
        MyThread mr3 = new MyThread();

        mr1.start();
        mr2.start();
        mr3.start();

        try {
            // 主线程睡眠 5 秒后，唤醒子线程
            Thread.sleep(5000);
        } catch (InterruptedException e) {
            throw new RuntimeException(e);
        }

        synchronized (MyThread.LOCK){
            // 唤醒子线程
            MyThread.LOCK.notifyAll();
        }
    }
}
